﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Portalz.Engine;

namespace Portalz.FormTest
{
    public partial class CharacterSelection : Form
    {
        public CharacterSelection()
        {
            InitializeComponent();
        }

        private void CharacterSelection_Load(object sender, EventArgs e)
        {
            loadCharacterList();
        }

        private void loadCharacterList()
        {
            lstCharacters.Items.Clear();
            foreach (string character in Data.characterList)
            {
                if (character != null)
                    lstCharacters.Items.Add(character);
            }
            lstCharacters.SelectedIndex = 0;
        }

        private void lstCharacters_SelectedIndexChanged(object sender, EventArgs e)
        {
            Character character = new Character(lstCharacters.SelectedItem.ToString());
            lblName.Text = character.Name;
            lblLevel.Text = character.Level.ToString() ;
        }

        private void btnCreate_Click(object sender, EventArgs e)
        {
            Character character = new Character("Player " + (Data.characterList.Length), 0);
            character.Save();
            loadCharacterList();
            lstCharacters.SelectedIndex = lstCharacters.Items.Count - 1;
        }


    }
}
